<div class="fm-content">
    <!-- 最上面标题栏 -->
    <div class="title">
        <i nz-icon [type]="'desktop'"></i>
        &nbsp;&nbsp;报表定义
    </div>
    <!-- 内容 -->
    <div class="work">

        <!-- 查询框 -->
        <div class="top">
            <!-- first-input -->
            <!-- <input nz-input placeholder="主键ID" class="fm-input" [(ngModel)]="fs.queryObject['id:like']" /> -->
            <input nz-input placeholder="名称" class="fm-input first-input"
                [(ngModel)]="fs.queryObject['dataname:like']" />
            <input nz-input placeholder="数据表名" class="fm-input" [(ngModel)]="fs.queryObject['datatable:like']" />
            <!-- <input nz-input placeholder="元数据" class="fm-input" [(ngModel)]="fs.queryObject['metadata:like']" /> -->
            <nz-tree-select class="fm-input" nzPlaceHolder="请选择" [nzDropdownMatchSelectWidth]="true"
                [nzDropdownStyle]="{ 'max-height': '300px' }" [(ngModel)]="fs.queryObject['adminfields']"
                name="adminfields" [nzAsyncData]="true" [nzNodes]="administrativeDic.treeDatas" [nzPlaceHolder]="'政区'">
            </nz-tree-select>
            <!-- <nz-input-number
                		placeholder="排序" class="fm-input" [(ngModel)]="fs.queryObject['order']"
                    [nzMin]="1" [nzMax]="100" [nzStep]="1" >
                </nz-input-number> -->
            <!-- <input nz-input placeholder="有效" class="fm-input" [(ngModel)]="fs.queryObject['valid:like']" /> -->
            <nz-button-group>
                <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
                <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
            </nz-button-group>
            <div class="tool-right">
                <nz-button-group>
                    <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
                    <button nz-button (click)="fs.editRow()">编辑</button>
                    <button nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntitys()" nzPlacement="bottomRight"
                        nz-button>删除</button>
                </nz-button-group>
            </div>
        </div>

        <!-- 右则样表单主体 -->
        <div class="work-content">
            <div class="table">
                <nz-table nzSize="middle" nzShowSizeChanger [nzPageSizeOptions]='[ 10, 15, 20, 30, 40, 50 ]'
                    [nzFrontPagination]="false" [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing"
                    [nzTotal]="fs.rowsCount" [(nzPageIndex)]="fs.pageIndex" [(nzPageSize)]="fs.pageSize"
                    (nzPageIndexChange)="fs.loadData()" (nzPageSizeChange)="fs.loadData(true)">
                    <thead>
                        <tr>
                            <th nzShowCheckbox [(nzChecked)]="fs.allChecked" [nzIndeterminate]="fs.indeterminate"
                                (nzCheckedChange)="fs.checkAll($event)"></th>
                            <!-- <th nzWidth="20%">主键ID</th> -->
                            <th>名称</th>
                            <th>数据表名</th>
                            <th>元数据</th>
                            <th>政区</th>
                            <!-- <th>排序</th> -->
                            <th>有效</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr *ngFor="let data of fs.datas">
                            <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="fs.refreshCheckStatus()">
                            </td>
                            <!-- <td><span (click)="fs.editRow(data)" class="form-edit"></span></td> -->
                            <!-- <td>{{data.id}}</td> -->
                            <td>
                                <span class="form-edit" (click)="fs.editRow(data)">{{data.dataname}}</span>
                            </td>
                            <td>{{data.datatable}}</td>
                            <td>{{data.metadataName}}</td>
                            <td>{{data.adminName}}</td>
                            <!-- <td>{{data.order}}</td> -->
                            <td>{{data.valid | boolReform }}</td>
                        </tr>
                    </tbody>
                </nz-table>
            </div>
        </div>

        <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="fs.isEditVisible"
            (nzOnCancel)="fs.closeEdit()">
            <form nz-form [nzLayout]="'inline'">
                <!-- <div nz-row [nzGutter]="24">
                <div nz-col [nzSpan]="12">
                    <nz-form-item>
                        <nz-form-label nzRequired class="form-label">主键ID</nz-form-label>
                        <nz-form-control class="form-control" [nzValidateStatus]="id.invalid?'error':'success'" nzHasFeedback>
                            <input nz-input [(ngModel)]="fs.er.id"
                                	name="id" required #id="ngModel" />
                        </nz-form-control>
                    </nz-form-item>
                </div>
            </div> -->
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">名称</nz-form-label>
                            <nz-form-control class="form-control"
                                [nzValidateStatus]="dataname.invalid?'error':'success'" nzHasFeedback>
                                <input nz-input [(ngModel)]="fs.er.dataname" name="dataname" required
                                    #dataname="ngModel" />
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">数据表名</nz-form-label>
                            <nz-form-control class="form-control"
                                [nzValidateStatus]="datatable.invalid?'error':'success'" nzHasFeedback>
                                <input nz-input [(ngModel)]="fs.er.datatable" name="datatable" required
                                    #datatable="ngModel" />
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                </div>
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">元数据</nz-form-label>
                            <nz-form-control class="form-control"
                                [nzValidateStatus]="metadata.invalid?'error':'success'" nzHasFeedback>
                                <nz-tree-select nzPlaceHolder="请选择" [nzDropdownMatchSelectWidth]="true" required
                                    #metadata="ngModel" [nzDropdownStyle]="{ 'max-height': '300px' }"
                                    [(ngModel)]="fs.er.metadata" name="metadata" [nzAsyncData]="true"
                                    [nzNodes]="metadataDic.treeDatas">
                                </nz-tree-select>
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">政区</nz-form-label>
                            <nz-form-control class="form-control"
                                [nzValidateStatus]="adminfields.invalid?'error':'success'" nzHasFeedback>
                                <nz-tree-select required class="form-control" nzPlaceHolder="请选择"
                                    [nzDropdownMatchSelectWidth]="true" [nzDropdownStyle]="{ 'max-height': '300px' }"
                                    [(ngModel)]="fs.er.adminfields" name="adminfields" #adminfields="ngModel"
                                    [nzAsyncData]="true" [nzNodes]="administrativeDic.treeDatas">
                                </nz-tree-select>
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                </div>
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">排序</nz-form-label>
                            <nz-form-control class="form-control" [nzValidateStatus]="order.invalid?'error':'success'"
                                nzHasFeedback>
                                <nz-input-number [(ngModel)]="fs.er.order" name="order" required #order="ngModel"
                                    [nzMin]="1" [nzMax]="100" [nzStep]="1" class="form-control">
                                </nz-input-number>
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">有效</nz-form-label>
                            <nz-form-control class="form-control">
                                <nz-switch nzCheckedChildren="有" nzUnCheckedChildren="无" [(ngModel)]="fs.er.valid"
                                    name="valid"></nz-switch>
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                </div>
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="24">
                        <nz-form-label style="float:left;" nzRequired class="form-label">表头格式</nz-form-label>
                        <div style="width: 77%;float: left;">
                            <textarea rows="6" nz-input [(ngModel)]="fs.er.tableHead" name="tableHead" required
                                #tableHead="ngModel"></textarea>
                        </div>
                    </div>
                </div>
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="24" class="form-button-align">
                        <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
                        <button nz-button nzType="primary"
                            [disabled]='dataname.invalid || datatable.invalid || metadata.invalid || adminfields.invalid || order.invalid || tableHead.invalid'
                            (click)="fs.save()" [nzLoading]="fs.isSaveing">保存</button>
                    </div>
                </div>
            </form>
        </nz-modal>
    </div>
</div>